package field_REGEX_Definitions.Other;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import field_REGEX_Definitions.Field;
import fields.*;

public class Collection_Date implements Field{
	
	private Pattern collection_date = Pattern.compile("date[:\\n\\s]*(\\S+)",Pattern.CASE_INSENSITIVE);
	private String field;
	private String rest = "";
	private String type = "other";
	
	public boolean matches(String input) {
		Matcher matcher = collection_date.matcher(input);
		boolean result = matcher.find();
		if (result) {
			field = "Collection Date";
			rest = matcher.group(1);
		}
		return result;
	}
	
	public String getFieldName(){
		return field;
	}

	public FileCollectionData execute() {
		return new FileCollectionData(field,"Other",rest);
	}

	@Override
	public String getFieldType() {
		return type;
	}
}
